/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: support lock MSR_IA32_FEAT_CTL register for x86
 * Author: Abbott Liu <liuwenliang@huawei.com>
 * Create: 2023-09-14
 */
#include "internal_ghes_recheck.h"

#ifdef CONFIG_RTOS_HAL_GHES_CALLBACK
static void (*ghes_recheck)(struct acpi_hest_generic_status *estatus);

/* caller ensures that the parameter is not NULL */
void call_ghes_recheck(struct acpi_hest_generic_status *estatus)
{
	void (*fun_ghes_recheck)(struct acpi_hest_generic_status *) = NULL;
	int sev = ghes_severity(estatus->error_severity);
	rcu_read_lock();
	fun_ghes_recheck = rcu_dereference(ghes_recheck);
	if (fun_ghes_recheck != NULL)
		fun_ghes_recheck(estatus);
	else if (sev >= GHES_SEV_PANIC)
		estatus->error_severity = GHES_SEV_RECOVERABLE;
	rcu_read_unlock();
}

int register_ghes_recheck(void(*ghes_recheck_handle)(struct acpi_hest_generic_status *))
{
	rcu_assign_pointer(ghes_recheck, ghes_recheck_handle);
	return 0;
}
EXPORT_SYMBOL(register_ghes_recheck);
#endif
